package cn.tedu.charging.order.utils;

import cn.tedu.charging.order.pojo.po.StudentEsPO;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;

import java.util.*;

public class StudentDataGenerator {


    private static final String[] ADDRESSES = {
            "北京市海淀区中关村大街", "上海市浦东新区张江高科技园区", "广州市天河区珠江新城",
            "深圳市南山区科技园", "杭州市西湖区文三路", "南京市鼓楼区中山北路",
            "成都市武侯区天府软件园", "武汉市洪山区光谷广场", "西安市雁塔区高新路",
            "重庆市渝北区光电园", "苏州市工业园区金鸡湖大道", "天津市滨海新区开发区"
    };

    /**
     * 生成指定数量的随机学生数据
     */
    public static List<StudentEsPO> generateRandomStudents(int count) {
        List<StudentEsPO> students = new ArrayList<>();
        Random random = new Random();

        for (int i = 0; i < count; i++) {
            students.add(createRandomStudent(random));
        }

        return students;
    }

    /**
     * 生成单个随机学生
     */
    private static StudentEsPO createRandomStudent(Random random) {
        StudentEsPO student = new StudentEsPO();

        student.setId(UUID.randomUUID().toString());
        student.setStudentNo("2506VN" + String.format("%06d", random.nextInt(1000000)));
        student.setName(NickNameGenerator.generate());
        student.setAge(18 + random.nextInt(8));
        student.setBirthday(generateRandomBirthday(random));
        student.setAddress(ADDRESSES[random.nextInt(ADDRESSES.length)]);
        return student;
    }

    /**
     * 生成随机生日（1998-2005年）
     */
    private static Date generateRandomBirthday(Random random) {
        // 1998年到2005年
        int year = 1998 + random.nextInt(8);
        int month = random.nextInt(12);
        int day = 1 + random.nextInt(28); // 简单处理，避免月份天数问题

        Calendar calendar = Calendar.getInstance();
        calendar.set(year, month, day);
        return calendar.getTime();
    }
}
